<?php

namespace app\controller\v1\admin;

use app\BaseController;
use app\common\Send;
use app\service\MemberVipService;
use think\App;
use think\Request;

class MemberVip extends BaseController
{
    use Send;
    protected $memberVipService;

    public function __construct(App $app,MemberVipService $memberVipService)
    {
        parent::__construct($app);
        $this->memberVipService = $memberVipService;
    }

    /**
     * 获取会员VIP等级列表
     */
    public function index(Request $request)
    {
        $params = $request->param();
        $result = $this->memberVipService->list($params);
        return self::success($result);
    }

    /**
     * 创建会员VIP等级
     */
    public function save(Request $request)
    {
        $params = $request->param();
        $result = $this->memberVipService->save($params);
        return self::success($result);
    }

    /**
     * 获取指定会员VIP等级
     */
    public function read($id)
    {
        $result = $this->memberVipService->detail($id);
        return self::success($result);
    }

    /**
     * 更新会员VIP等级
     */
    public function update(Request $request, $id)
    {
        $params = $request->param();
        $result = $this->memberVipService->update($id, $params);
        return self::success($result);
    }

    /**
     * 删除会员VIP等级
     */
    public function delete($id)
    {
        $result = $this->memberVipService->delete($id);
        return self::success($result);
    }

    /**
     * 获取所有可用的会员VIP等级
     */
    public function all(Request $request)
    {
        $params = $request->param();
        $result = $this->memberVipService->getAll($params);
        return self::success($result);
    }
}
